package com.zhengxyou.jetpackdemo.butterknife;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.zhengxyou.jetpackdemo.R;

import java.util.List;

import androidx.appcompat.app.AppCompatActivity;
import butterknife.BindColor;
import butterknife.BindDimen;
import butterknife.BindDrawable;
import butterknife.BindString;
import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnLongClick;

/**
 * 官方地址 @see http://jakewharton.github.io/butterknife/
 */
public class ButterKnifeActivity extends AppCompatActivity {
    @BindString(R.string.butter_knife)
    String butterKnife;
    @BindView(R.id.tv_first)
    TextView tv_first;
    @BindView(R.id.tv_last)
    TextView tv_last;
    @BindView(R.id.btn_change)
    Button btn_change;
    @BindView(R.id.btn_status)
    Button btn_status;
    @BindDimen(R.dimen.dimen_butterKnife)
    int textSize;

    @BindDrawable(R.drawable.ic_dashboard_black_24dp)
    Drawable grapic;
    @BindColor(R.color.colorAccent)
    int colorAccent;

    /**
     * 同一个类型的View
     */
    @BindViews({R.id.tv_first, R.id.tv_last})
    List<TextView> namVies;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_butter_kinfe);
        ButterKnife.bind(this);

        btn_change.setText("please click");

    }

    public static void start(Context context) {
        Intent starter = new Intent(context, ButterKnifeActivity.class);
        context.startActivity(starter);
    }

    @OnClick(R.id.btn_change)
    void onChangeClick(View view) {
        tv_first.setText(butterKnife);
        tv_first.setTextSize(textSize);
    }

    @OnClick(R.id.btn_status)
    void onChangeStatus() {
        tv_last.setText("Status");

    }

    @OnClick({R.id.tv_first, R.id.tv_last, R.id.btn_change})
    void onTvClick(View view) {
        switch (view.getId()) {
            case R.id.btn_change:
                Toast.makeText(this, "btn_change", Toast.LENGTH_LONG).show();
                break;
            case R.id.tv_first:
                Toast.makeText(this, "first name", Toast.LENGTH_LONG).show();
                break;
            case R.id.tv_last:
                Toast.makeText(this, "last name", Toast.LENGTH_LONG).show();
                break;
        }
    }

    @OnLongClick(R.id.btn_status)
    boolean onBtnLong() {
        Toast.makeText(this, "btn_status Long Click", Toast.LENGTH_LONG).show();
        return true;
    }

//    @OnItemClick
//    @OnItemSelected
}
